package top.blackr.folivora.common.security.auth;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import top.blackr.folivora.common.core.enums.ResultEnum;
import top.blackr.folivora.common.core.exception.BizException;
import top.blackr.folivora.common.security.auth.impl.LoginService;

import java.util.Map;

@Component
@AllArgsConstructor
public class LoginAuthenticationFactory {

    private Map<String, LoginService> loginServiceMap;

    public LoginService getLoginService(String loginType) {
        if (loginType == null || !loginServiceMap.containsKey(loginType.toLowerCase())) {
            throw new BizException(ResultEnum.LOGIN_TYPE_NOT_SUPPORTED);
        }
        return loginServiceMap.get(loginType);
    }
}
